package com.kaiyiweitong.tongxing.fragment.service_info;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.kaiyiweitong.tongxing.R;
import com.kaiyiweitong.tongxing.adapter.ServiceTagAdapter;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagFlowLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/12/19 0019.
 */

public class SpecificationFragment extends Fragment {
    @Bind(R.id.tfl_service_year)
    TagFlowLayout mTflServiceYear;
    @Bind(R.id.tfl_service_way)
    TagFlowLayout mTflServiceWay;
    @Bind(R.id.tfl_apply_method)
    TagFlowLayout mTflApplyMethod;
    @Bind(R.id.service_address)
    TextView mServiceAddress;
    private View mView;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mView = inflater.inflate(R.layout.fragment_specification, null);
        ButterKnife.bind(this, mView);
        init();
        return mView;
    }

    private void init() {
        List<String> serviceYearList = new ArrayList<>();
        serviceYearList.add("一个月");
        serviceYearList.add("一个季度");
        serviceYearList.add("半年");
        serviceYearList.add("一年");
        ServiceTagAdapter serviceYearAdapter = new ServiceTagAdapter(serviceYearList, mListener);
        mTflServiceYear.setAdapter(serviceYearAdapter);
        mTflServiceYear.getChildAt(0).setSelected(true);


        List<String> serviceWayList = new ArrayList<>();
        serviceWayList.add("标准服务");
        serviceWayList.add("上门服务");
        ServiceTagAdapter serviceWayAdapter = new ServiceTagAdapter(serviceWayList, mListener);
        mTflServiceWay.setAdapter(serviceWayAdapter);
        mTflServiceWay.getChildAt(0).setSelected(true);


        List<String> applyMethodList = new ArrayList<>();
        applyMethodList.add("不限");
        applyMethodList.add("零申报");
        applyMethodList.add("非零申报");
        ServiceTagAdapter applyMethodAdapter = new ServiceTagAdapter(applyMethodList, mListener);
        mTflApplyMethod.setAdapter(applyMethodAdapter);
        mTflApplyMethod.getChildAt(0).setSelected(true);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @OnClick({R.id.cut_city, R.id.choose_address})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.cut_city:

                break;
            case R.id.choose_address:

                break;
        }
    }

    private ServiceTagAdapter.onClickListener mListener = new ServiceTagAdapter.onClickListener() {
        @Override
        public void onClick(FlowLayout layout, int position) {
            switch (layout.getId()) {
                case R.id.tfl_service_year:

                    break;
                case R.id.tfl_service_way:

                    break;
                case R.id.tfl_apply_method:

                    break;
            }
        }
    };
}
